//
//  BillDetailViewController.m
//  YTwallet
//
//  Created by ZhangLin on 2019/3/21.
//  Copyright © 2019年 hadrlog. All rights reserved.
//

#import "BillDetailViewController.h"
#import "BillDetailView.h"
@interface BillDetailViewController ()
@property(nonatomic,strong)BillDetailView *bv;

@end

@implementation BillDetailViewController

-(void)loadView
{
    [super loadView];
    self.bv = [[BillDetailView alloc] initWithFrame:self.view.bounds];
    self.view = self.bv;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"账单详情";
    self.view.backgroundColor = [UIColor colorWithRed:242 / 255.0  green:244 / 255.0  blue:246 / 255.0 alpha:1];
    self.bv.accountNumLab.attributedText = [self dealAccountLabText];
    self.bv.consumeSuccessLab.text = self.statusName;
//    self.bv.consumeValueTypeLab.text = self.businessType;
    if ([@"0" isEqualToString:self.businessType]) {
        self.bv.consumeValueTypeLab.text = @"信用卡收款";
        self.bv.imv.image = [UIImage imageNamed:@"bill_icon_card"];
    }else if ([@"1" isEqualToString:self.businessType]) {
        self.bv.consumeValueTypeLab.text = @"刷卡收款";
        self.bv.imv.image = [UIImage imageNamed:@"bill_icon_shua"];
    }else if ([@"2" isEqualToString:self.businessType]) {
        self.bv.consumeValueTypeLab.text = @"提现";
        self.bv.imv.image = [UIImage imageNamed:@"bill_icon_cash"];
    }else
    {
        self.bv.consumeValueTypeLab.text = @"未知类型";
        self.bv.imv.image = [UIImage imageNamed:@"bill_icon_card"];
        
    }
    self.bv.receiptValueCardLab.text = self.receiveCardNo;
    self.bv.orderValueNumLab.text = self.orderId;
    self.bv.tradeTimeValueLab.text = self.tradeTime;
    
    [self.bv.CCopyBtn addTarget:self action:@selector(CCopyBtnAction) forControlEvents:(UIControlEventTouchUpInside)];
    
}

-(void)CCopyBtnAction
{
    NSLog(@"点击复制");
    if (self.bv.orderValueNumLab.text.length > 0) {
        [self showSuccessResultTips:@"复制成功" animated:YES forSeconds:SUCCESS_SHOW_TIME_DEF
                    completionBlock:^{
                        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
                        pasteboard.string = self.bv.orderValueNumLab.text;
                    }];
        
    }
}
-(NSAttributedString *)dealAccountLabText
{
    if (self.payAmount.length != 0) {
        NSString *str = [@"￥" stringByAppendingString:self.payAmount];
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
        [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:24] range:NSMakeRange(0, 1)];
        [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:35] range:NSMakeRange(1, str.length - 1)];
        [attributedString addAttribute:NSForegroundColorAttributeName value:ETColorWithRGB(0, 0, 0) range:NSMakeRange(0, str.length - 1)];
        return attributedString;
    }else
    {
        return nil;
    }
    
}


@end
